#include <iostream>
#include <vector>
#include <unordered_map>
#include <algorithm>

using namespace std;

class Solution
{
public:
    vector<int> arrayRankTransform(vector<int> &arr)
    {
        vector<int> srt = arr;
        sort(srt.begin(), srt.end());
        unordered_map<int, int> m;
        vector<int> ans(arr.size());

        for(auto &a : srt)
        {
            if(!m.count(a))
            {
                m[a]=m.size() + 1;
            }
        }
        for(int i=0;i<ans.size();i++)
        {
            ans[i] = m[arr[i]];
        }

        return ans;
    }
};